home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 July / APC47-2.ISO / mac / macsbug / macsbug.hqx / MacsBug 6.5.4a6 / Building dcmds / C Samples / Where.c < prev   
Encoding:
C/C++ Source or Header  |  1998-09-22  |  2.3 KB  |  101 lines

  1. /*
  2.     File:        Where.c
  3.  
  4.     Contains:    A sample dcmd which displays information about a trap or address.
  5.  
  6.     Written by:    JM3 = Jim Murphy
  7.  
  8.     Copyright:    ⌐ 1991, 1994, 1996, 1998 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Jim Murphy
  13.  
  14.         Other Contact:        Dave Lyons
  15.  
  16.         Technology:            MacsBug 6.5.x
  17.  
  18.     Writers:
  19.  
  20.         (DAL)    Dave Lyons
  21.  
  22.     Change History (most recent first):
  23.  
  24.          <5>     1/13/98    DAL        ElseCop 1.0.
  25.          <4>   25-Jan-96    JM3        Updated the sample build commands to be current.
  26.          <3>   11-Dec-94    JM3        Bleh. I somehow deleted a couple of lines at the end.
  27.          <2>   10-Dec-94    JM3        Updated for new version 3 dcmd requirements.
  28.  
  29.     The following MPW commands will build the dcmd and copy it to the "Debugger Prefs" file
  30.     in the System folder. The dcmd's name in MacsBug will be the name of the file built by
  31.     the Linker.
  32.  
  33.     C Where.c
  34.     Link -o Where -sg Main=STDCLIB,STDIO,SANELIB dcmdGlue.a.o Where.c.o" "{Libraries}Runtime.o"
  35.     BuildDcmd Where 199 -format3
  36.     Echo 'include "Where";'    |    Rez -a -o "{systemFolder}Debugger Prefs"
  37.  
  38.  */
  39.  
  40. #include <Memory.h>
  41. #include <Types.h>
  42. #include "dcmd.h"
  43.  
  44.  
  45. pascal void CommandEntry (dcmdBlock* paramPtr)
  46. {
  47.  
  48.     short    ch;
  49.     long    address;
  50.     Boolean    ok;
  51.     Str255    name;
  52.  
  53.     static const char usageStr[] = "\p[addr | trap]";
  54.  
  55.     switch (paramPtr->request)
  56.     {
  57.         case dcmdInit:
  58.             break;
  59.  
  60.         case dcmdHelp:
  61.             dcmdDrawLine("\pDisplay information about the address or trap.");
  62.             dcmdDrawLine("\pIf no parameter then use PC as the address.");
  63.             break;
  64.  
  65.         case dcmdGetInfo:
  66.             * (long *) &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->dcmdVersion = 0x03008000; // version 3.0 final
  67.             BlockMoveData(&usageStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->usageStr, usageStr[0]+1);
  68.             break;
  69.  
  70.         case dcmdDoIt:
  71.             if (dcmdPeekAtNextChar () == '\n')
  72.             {
  73.                 address = paramPtr->registerFile[PCRegister];
  74.             }
  75.             else
  76.             {
  77.                 ch = dcmdGetNextExpression (&address, &ok);
  78.                 if (!ok)
  79.                 {
  80.                     dcmdDrawLine ("\pSyntax error");
  81.                     return;
  82.                 }
  83.             }
  84.  
  85.             if (address >= 0x0000A000 && address <= 0x0000ABFF)
  86.             {
  87.                 dcmdGetTrapName (address, name);
  88.                 dcmdDrawLine (name);
  89.             }
  90.             else
  91.             {
  92.                 dcmdGetNameAndOffset (address, name);
  93.                 if (name[0] > 0)
  94.                     dcmdDrawLine (name);
  95.                 else
  96.                     dcmdDrawLine ("\pNo procedure name found");
  97.             }
  98.             break;
  99.         }
  100. } // CommandEntry
  101.